package com.zxy.ziems.server.controller;

import com.zxy.btp.web.util.TokenUtils;
import com.zxy.ziems.server.dto.zieceuse.*;
import com.zxy.ziems.server.statistics.service.ZieceDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @Description: 用于给厂务中心传数据
 *
 */
@RestController
@Validated
@RequestMapping("/api/zieceData")
public class ZieceDataController {

    @Autowired
    private ZieceDataService zieceDataService;

    /**
     * 获取基础、运行、水、电、气、空调所有数据
     * 获取某一天的数据
     * @return AcData
     */
    @GetMapping("/getAllData")
    public List<Object> getAllData(String dataClassify,LocalDate date){
        String userId = TokenUtils.getUserIdByToken();
        return zieceDataService.getAllData(dataClassify,date);
    }

    /**
     * 获取基础数据
     * 获取某一天的数据
     * @return BasicData
     */
    @GetMapping("/getBasicData")
    public BasicData getBasicData(String dataClassify,LocalDate date){
        String userId = TokenUtils.getUserIdByToken();
        return zieceDataService.getBasicData(dataClassify,date);
    }


    /**
     * 获取电相关数据
     * 获取某一天的数据
     * @return ElectricityData
     */
    @GetMapping("/getElectricityData")
    public ElectricityData getElectricityData(String dataClassify,LocalDate date){
        String userId = TokenUtils.getUserIdByToken();
        return zieceDataService.getElectricityData(dataClassify,date);
    }

    /**
     * 获取水相关数据
     * 获取某一天的数据
     * @return WaterData
     */
    @GetMapping("/getWaterData")
    public WaterData getWaterData(String dataClassify,LocalDate date){
        String userId = TokenUtils.getUserIdByToken();
        return zieceDataService.getWaterData(dataClassify,date);
    }

    /**
     * 获取气相关数据
     * 获取某一天的数据
     * @return GasData
     */
    @GetMapping("/getGasData")
    public GasData getGasData(String dataClassify,LocalDate date){
        String userId = TokenUtils.getUserIdByToken();
        return zieceDataService.getGasData(dataClassify,date);
    }

    /**
     * 获取空调相关数据
     * 获取某一天的数据
     * @return AcData
     */
    @GetMapping("/getAcData")
    public AcData getAcData(String dataClassify,LocalDate date){
        String userId = TokenUtils.getUserIdByToken();
        return zieceDataService.getAcData(dataClassify,date);
    }


    /**
     * 运行数据相关
     * 获取某一天的数据
     * @return AcData
     */
    @GetMapping("/getProcessData")
    public AcData getProcessData(String dataClassify,LocalDate date){
        String userId = TokenUtils.getUserIdByToken();
        return zieceDataService.getProcessData(dataClassify,date);
    }


}
